var e = require("../../0E8B0BC42FB173BF68ED63C34BB4DCA6.js"), n = require("../../30A2BE152FB173BF56C4D61233F4DCA6.js"), t = require("../../A7DBB9B62FB173BFC1BDD1B19505DCA6.js");

Page({
    data: {
        isx: /iphone10|iphone x/i.test(wx.getSystemInfoSync().model),
        isAndroid: /android/i.test(wx.getSystemInfoSync().system),
        measure: null,
        measures: null,
        index: 0,
        envelope: [ ".66", ".68", ".88", ".99" ],
        punishType: null,
        openSetting: !1,
        currentPages: 1
    },
    onLoad: function(e) {
        this.setData({
            currentPages: getCurrentPages().length
        });
        var n = e.punishType;
        console.log("options:", e), n ? this.punish(n) : getApp().globalData.punishment.random && this.randomPunish();
    },
    randomPunish: function() {
        var e = getApp().globalData.punishment, t = new Array();
        e.envelope && t.push("envelope"), e.drink && t.push("drink"), e.truth && t.push("truth"), 
        e.risk && t.push("risk");
        var i = n(t)[0];
        this.punish(i);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function(t) {
        return {
            title: n(e.SHARE.title)[0],
            path: "/pages/index/index",
            imageUrl: "/assets/" + n(e.SHARE.image)[0]
        };
    },
    onClickType: function(e) {
        var n = e.currentTarget.id;
        this.punish(n);
    },
    punish: function(i) {
        if ("envelope" === i) {
            var a = n(this.data.envelope), s = t.randomNum(0, 9) + a[0];
            console.log(""), this.setData({
                punishType: i,
                measure: s
            });
        } else {
            var o = n(e.MEASURES[i]);
            this.setData({
                punishType: i,
                measures: o,
                measure: o[0],
                index: 0
            });
        }
    },
    onChange: function() {
        if ("envelope" === this.data.punishType) {
            var e = n(this.data.envelope), i = t.randomNum(0, 9) + e[0];
            this.setData({
                measure: i
            });
        } else {
            var a = this.data.measures.length, s = this.data.index <= a - 1 ? this.data.index + 1 : 0;
            this.setData({
                measure: this.data.measures[s],
                index: s
            });
        }
    },
    onChangeRandom: function() {
        this.randomPunish();
    },
    back: function() {
        t.navigateBack();
    },
    onAgain: function() {
        t.navigateBack();
    },
    changeSetting: function(e) {
        console.log("changeSetting:", e), this.setData({
            openSetting: !1
        });
    },
    openSetting: function() {
        console.log("openSetting"), this.setData({
            openSetting: !0
        });
    },
    openSurrender: function() {
        wx.navigateTo({
            url: "/pages/touxiang/index"
        });
    }
});